<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
	<title><spring:message code="message.list.ShouHuoQuqRen"/></title>
	<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1><spring:message code="message.list.ShouHuoQuqRen"/></h1>
        <ol class="breadcrumb">
        	<li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li><a href="#">交易</a></li>
            <li><a href="#"><spring:message code="message.list.DingDanGuanLi"/></a></li>
            <li><a href="#"><spring:message code="message.list.ShouHuoRuKu"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.list.ShouHuoQuqRen"/></a></li>
        </ol>
    </section>
    
    <section class="content">
        <div class="box box-success">
            <div class="box-body">
                <div class="input" style="margin-top:-5px">
			 	    <div class="textalign1"><spring:message code="message.listForm.DingDanBaoHao"/><spring:message code="message.yanZheng.maoHao"/></div>
					<div class="boxinput">
	                    <input type="text" class="textinput"  id="orderPackId" name="orderPackId" placeholder="<spring:message code="message.listForm.DingDanBaoHao"/> "/> 
	                </div>
					<div class="textalign1">
						<spring:message code="message.listForm.PeiSongQiYe"/><spring:message code="message.yanZheng.maoHao"/></div>
					<div class="boxinput"> 
						<input type="text" class="textinput" id="delCompName" name="delCompName" placeholder="<spring:message code="message.listForm.PeiSongQiYe"/>/<spring:message code="message.listForm.pinYinMa"/>"/>
					</div>
					<div class="textalign1"><spring:message code="message.listForm.CaiGouRiQi"/><spring:message code="message.yanZheng.maoHao"/></div>
	                <div class="boxinput"> 
                       <table style="width:100%">
                                <tr>
                                    <td style="width:50%">
                                        <input id="submitStartDatetime" name="submitStartDatetime" type="text" class="textinput"   placeholder="yyyy-MM-dd" 
												data-date-fmt="yyyy-MM-dd" onFocus="var endDate=$dp.$('submitEndDatetime');WdatePicker({maxDate:'#F{$dp.$D(\'submitEndDatetime\')}'})" />
                                    </td>
                                    <td>&nbsp;-&nbsp;</td>
                                    <td style="width:50%">
                                        <input id="submitEndDatetime" name="submitEndDatetime" type="text" class="textinput" placeholder="yyyy-MM-dd" 
												data-date-fmt="yyyy-MM-dd" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'submitStartDatetime\')}'})" />
                                    </td>
                                </tr>
                            </table>
                    </div>
                   
                    <div class="textalign1" >
					<button type="button" onclick="gridSerch();" class="btn btn-success btn-sm" id="selectDicCompType"><spring:message code="message.button.seachSpacing"/></button>
                    </div>
                     </div>
				
                </div>
            </div>
        </div>


        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
       
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
  //绑定回车
    $('#orderPackId,#delCompName,#submitStartDatetime,#submitEndDatetime,#orderStartDatetime,#orderEndDatetime,#confirmStartDatetime,#confirmEndDatetime,#psStartDatetime,#psEndDatetime,#outStartDatetime,#outEndDatetime,#recpStartDatetime,#recpEndDatetime').bind('keydown', function(event) { 
        if (event.keyCode == "13") {
            $('#selectDicCompType').click();
        }
    });	
    $("#orderPackId").focus();//加载页面光标在第一个查询框内
    
    
        $(function () {
         
            $("#gridlist").jqGrid({
            	url: "${ctx}/purOrderInfo/getConfirmRecpDataList.html",
                mtype: "POST",
                datatype: "json",
                postData:{
    	        		"recpStartDatetime":$('#recpStartDatetime').val(),
    	        		"recpEndDatetime":$('#recpEndDatetime').val()
						},
                autowidth: true,
                shrinkToFit: true,
              //  height: 325,
                colNames: [
                           '<spring:message code="message.jqGrid.cz"/>',
                           '<spring:message code="message.listForm.DingDanBaoHao"/>',
						   '<spring:message code="message.listForm.CaiGouTiaoMu"/>',
						   '<spring:message code="message.listForm.CaiGouZongJinE"/>',
                           '<spring:message code="message.listForm.PeiSongQiYe"/>',
                           '<spring:message code="message.listForm.CaiGouShiJian"/>',
                           '<spring:message code="message.lable.hospRemark"/>'
                           ],
                colModel: [
                    { name: 'oper', width: 50 , align:"center",sortable: false,formatter:function(cellvalue, options,rowdata) {
                    	 return orderDetailLink(rowdata.orderPackId,rowdata.delCompName,rowdata.delMoney);
                       }
                    },
					{ name: 'orderPackId', width: 180 , align:"center" ,sortable: false},
					{ name: 'goodsNum', width: 80 , align:"center",sortable: false },
					{ name: 'totalProPrice', width: 80 , align:"right" ,sortable: false},
                    { name: 'delCompName', width: 190, align:"left" ,sortable: false/* ,
						 formatter:function(cellvalue, options,row) {
							 return "<a href=\"javascript:showCompInfo('"+row.delCompId+"')\">"+cellvalue+"</a>"
						 } */
					},
                    { name: 'submitDatetime', width: 140, align:"center" ,sortable: false},
					 { name: 'remarks', width: 250 , align:"left" ,sortable: false }
                ],
                rowNum: 20,
                rowList: [10, 20, 50, 100],
                rownumbers: true,
                pager: "#gridpage",
                multiselect: false, 
                viewrecords: true,
                gridComplete:function(){
                	//序号列宽度自适应（参数为jqgridID）
                    autoRNWidth("gridlist");
                	//数据只有一条时默认选中（参数为jqgridID）
                    selectByOneData("gridlist");
                },
            	
                caption: "<spring:message code="message.list.DaiShouHuoDingDanLieBiao"/>",
                jsonReader: {
                    repeatitems: false,
                    id: "ids"
                }
            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
            $("#gridlist").jqGrid("setGridHeight", create());
        });
        
        
        
        
        
        //查询
        function gridSerch() {
    		$("#gridlist").jqGrid('setGridParam',{  
    	        datatype:'json',
    	        postData:{
    	        		"orderPackId":$.trim($("#orderPackId").val()),
    	        		"delCompName":$.trim($("#delCompName").val()),
    	        		"submitStartDatetime":$.trim($("#submitStartDatetime").val()),
    	        		"submitEndDatetime":$.trim($("#submitEndDatetime").val()),
    	        },
    	        		page:1
    	    }).trigger("reloadGrid"); //重新载入  
    	}
        
	      //到货确认
            function batchModifyData(){
                var rowIds = $("#gridlist").jqGrid("getGridParam", "selarrrow") || [];
                if (rowIds.length <= 0) {
                    $.HN.message.alert('请选择订单包！', '<spring:message code="message.HN.alert.type"/>', 'warn');
                    return ;
                }	
                 var list = [];
                 for (var i=0; i<rowIds.length; i++) {
                     var rowId = rowIds[i];
                     var rowdata = $("#gridlist").jqGrid('getRowData', rowId);
                     //userList.push({"id":rowId, "name":(rowdata.name || "")});
                     list.push({"orderPackId":rowdata.orderPackId});
                 }
                 var dialog = top.dialog.get(window);
                 dialog.close(list); // 关闭（隐藏）对话框
                 dialog.save();                // 主动销毁对话框
                return false;
            }
	      
	      
	      
            //整包到货确认
            function allorderConfirmSelect(){
    	       	var rowIds = $("#gridlist").jqGrid("getGridParam", "selarrrow") || [];
    	   		if (rowIds.length <= 0) {
    			$.HN.message.alert("请选择要操作的行！", "<spring:message code="message.HN.alert.type"/>", "warn");
    			return;
    		 }
    	   		$.HN.message.confirm('确定加入所选吗？', '', '').on(function (e) {
    	   			if (e) {
    	   				var list = [];
    	   	    		for (var i=0; i<rowIds.length; i++) {
    	   	    			rowId = rowIds[i];
    	   	    			var rowdata = $("#gridlist").jqGrid('getRowData', rowId);
    	   	    			list.push({"orderPackId":rowdata.orderPackId});
    	   	    		}
    	   			$.post("${ctx}/purOrderInfo/multiConfirmByPack.html", {
    	   	    			"array" : json.jsonToString(list)
    	   	    		}, function(result) {
    	   	    			if (result.success) {
    	   	    				$.HN.message.alert("操作成功！", "<spring:message code="message.HN.alert.type"/>", "success");
    	   	    				gridSerch();
    	   	    				//document.location = "${ctx}/purOrderInfo/toConfirmRecpDetail.html";
    	   	    			} else {
    	   	    				$.HN.message.alert(result.msg , "<spring:message code="message.HN.alert.type"/>", "error");
    	   	    			}
    	   	    		}, "json")
    	   			}
    	   		}).trigger("reloadGrid"); //重新载入  ;
    	       }
          //整包未到货
            function allnotArrived(){
    	       	var rowIds = $("#gridlist").jqGrid("getGridParam", "selarrrow") || [];
    	       	if (rowIds.length <= 0) {
    			$.HN.message.alert("请选择要操作的行！", "<spring:message code="message.HN.alert.type"/>", "warn");
    			return;
    		}
    	   		$.HN.message.confirm('确定加入所选吗？', '', '').on(function (e) {
    	   			if (e) {
    	   				var list = [];
    	   	    		for (var i=0; i<rowIds.length; i++) {
    	   	    			rowId = rowIds[i];
    	   	    			var rowdata = $("#gridlist").jqGrid('getRowData', rowId);
    	   	    		list.push({"orderPackId":rowdata.orderPackId});
    	   	    		}
    	   			$.post("${ctx}/purOrderInfo/multiNoArrivedByPack.html", {
    	   	    			"array" : json.jsonToString(list)
    	   	    		}, function(result) {
    	   	    			if (result.success) {
    	   	    				gridSerch();
    	   	    				$.HN.message.alert("操作成功！", "<spring:message code="message.HN.alert.type"/>", "success");
    	   	    				gridSerch();
    	   	    				//document.location = "${ctx}/purOrderInfo/toConfirmRecpDetail.html";
    	   	    			} else {
    	   	    				$.HN.message.alert(result.msg , "<spring:message code="message.HN.alert.type"/>", "error");
    	   	    			}
    	   	    		}, "json")
    	   			}
    	   		}).trigger("reloadGrid"); //重新载入  ;
    	       }
          
            function orderDetailLink(orderPackId,delCompName,delMoney) {
                return "<a href='javascript:showOrderDetail(\"" + orderPackId + "\",\"" + delCompName + "\",\"" + delMoney + "\")'style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -140px -80px'  class='opIcon' title='<spring:message code="message.button.QueRenShouHuo"/>'></a>";
            }
          
            function showOrderDetail(orderPackId,delCompName,delMoney) {
                $.HN.window.open({
                    "id" : "orderDetail",
                    "title" : "订单明细     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color='red' size='1.5px'><spring:message code="message.title.TS"/></font>",
                    "url" : "${ctx}/purOrderInfo/toConfirmRecpDetail.html?orderPackId=" + orderPackId+"&delCompName="+delCompName+"&delMoney="+delMoney,
                    "callback" : function() {
                    	gridSerch();
                    }
                });
            }
          
          
    </script>
</body>
</html>